const connection = require('../db/mysql')

class FileService {
    async insertAvatar(filename, mimetype, size, userId) {
        let statement = 'INSERT INTO file(filename, mimetype, size, userId) VALUES(?, ?, ?, ?);'
        let params = [filename, mimetype, size, userId]
        let [ result ] = await connection.execute(statement, params)
        return result
    }

    async getFileInfoByName(filename) {
        let statement = 'SELECT * FROM file WHERE filename = ?;'
        let [ result ] = await connection.execute(statement, [filename])
        return result
    }
}

module.exports = new FileService()